home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / ooo2wordml_path.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  53KB  |  867 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: ooo2wordml_path.xsl,v $
  7.  
  8.     $Revision: 1.8 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:07:02 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  37.     <xsl:include href="../../common/math.xsl"/>
  38.     <xsl:template name="test-arc">
  39.         <xsl:call-template name="svg-arc2vml-arc">
  40.             <!--  M 125,75 a100,50 0 ?,? 100,50 -->
  41.             <xsl:with-param name="x0" select="125"/>
  42.             <xsl:with-param name="y0" select="75"/>
  43.             <xsl:with-param name="rx" select="100"/>
  44.             <xsl:with-param name="ry" select="50"/>
  45.             <xsl:with-param name="x-axis-rotation" select="0"/>
  46.             <xsl:with-param name="large-arc-flag" select="0"/>
  47.             <xsl:with-param name="sweep-flag" select="0"/>
  48.             <xsl:with-param name="x" select="225"/>
  49.             <xsl:with-param name="y" select="125"/>
  50.         </xsl:call-template>
  51.     </xsl:template>
  52.     <xsl:template name="test">
  53.         <xsl:call-template name="svgpath2vmlpath">
  54.             <xsl:with-param name="svg-path" select="'M 36.0 162.0 C 38.0 168.0 39.0-172.0 40.0 176.0 S 42.0 184.0 144.0 188.0'"/>
  55.         </xsl:call-template>
  56.     </xsl:template>
  57.     <xsl:template name="svgpath2vmlpath">
  58.         <xsl:param name="svg-path"/>
  59.         <xsl:param name="vml-path" select="''"/>
  60.         <xsl:param name="position" select="1"/>
  61.         <xsl:param name="last-command" select="'M'"/>
  62.         <xsl:param name="current-x" select="'0'"/>
  63.         <xsl:param name="current-y" select="'0'"/>
  64.         <xsl:variable name="command-and-newpos">
  65.             <xsl:call-template name="get-path-command">
  66.                 <xsl:with-param name="svg-path" select="$svg-path"/>
  67.                 <xsl:with-param name="position" select="$position"/>
  68.                 <xsl:with-param name="last-command" select="$last-command"/>
  69.             </xsl:call-template>
  70.         </xsl:variable>
  71.         <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
  72.         <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
  73.         <xsl:choose>
  74.             <xsl:when test="$command = 'M' ">
  75.                 <!-- absolute moveto -->
  76.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' m ' ) "/>
  77.                 <xsl:variable name="num-and-pos">
  78.                     <xsl:call-template name="get-number-after">
  79.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  80.                         <xsl:with-param name="position" select="$newpos"/>
  81.                         <xsl:with-param name="count" select="2"/>
  82.                     </xsl:call-template>
  83.                 </xsl:variable>
  84.                 <xsl:call-template name="svgpath2vmlpath">
  85.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  86.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  87.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  88.                     <xsl:with-param name="last-command" select="'L'"/>
  89.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  90.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  91.                 </xsl:call-template>
  92.             </xsl:when>
  93.             <xsl:when test="$command = 'm' ">
  94.                 <!-- relative moveto -->
  95.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' t ' ) "/>
  96.                 <xsl:variable name="num-and-pos">
  97.                     <xsl:call-template name="get-number-after">
  98.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  99.                         <xsl:with-param name="position" select="$newpos"/>
  100.                         <xsl:with-param name="count" select="2"/>
  101.                     </xsl:call-template>
  102.                 </xsl:variable>
  103.                 <xsl:call-template name="svgpath2vmlpath">
  104.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  105.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  106.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  107.                     <xsl:with-param name="last-command" select="'l'"/>
  108.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')    , ' ')  + $current-x"/>
  109.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ') + $current-y "/>
  110.                 </xsl:call-template>
  111.             </xsl:when>
  112.             <xsl:when test="$command = 'L' ">
  113.                 <!-- absolute lineto -->
  114.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
  115.                 <xsl:variable name="num-and-pos">
  116.                     <xsl:call-template name="get-number-after">
  117.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  118.                         <xsl:with-param name="position" select="$newpos"/>
  119.                         <xsl:with-param name="count" select="2"/>
  120.                     </xsl:call-template>
  121.                 </xsl:variable>
  122.                 <xsl:call-template name="svgpath2vmlpath">
  123.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  124.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  125.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  126.                     <xsl:with-param name="last-command" select="$command"/>
  127.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  128.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  129.                 </xsl:call-template>
  130.             </xsl:when>
  131.             <xsl:when test="$command = 'l' ">
  132.                 <!-- relative lineto -->
  133.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' r ' ) "/>
  134.                 <xsl:variable name="num-and-pos">
  135.                     <xsl:call-template name="get-number-after">
  136.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  137.                         <xsl:with-param name="position" select="$newpos"/>
  138.                         <xsl:with-param name="count" select="2"/>
  139.                     </xsl:call-template>
  140.                 </xsl:variable>
  141.                 <xsl:call-template name="svgpath2vmlpath">
  142.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  143.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  144.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  145.                     <xsl:with-param name="last-command" select="$command"/>
  146.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  147.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  148.                 </xsl:call-template>
  149.             </xsl:when>
  150.             <xsl:when test="$command = 'H' ">
  151.                 <!-- absolute horizontal  lineto -->
  152.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
  153.                 <xsl:variable name="num-and-pos">
  154.                     <xsl:call-template name="get-number-after">
  155.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  156.                         <xsl:with-param name="position" select="$newpos"/>
  157.                         <xsl:with-param name="count" select="1"/>
  158.                     </xsl:call-template>
  159.                 </xsl:variable>
  160.                 <xsl:call-template name="svgpath2vmlpath">
  161.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  162.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':')  , ' ' , $current-y , ' ') "/>
  163.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  164.                     <xsl:with-param name="last-command" select="$command"/>
  165.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  "/>
  166.                     <xsl:with-param name="current-y" select=" $current-y"/>
  167.                 </xsl:call-template>
  168.             </xsl:when>
  169.             <xsl:when test="$command = 'h' ">
  170.                 <!-- relative horizontal  lineto -->
  171.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
  172.                 <xsl:variable name="num-and-pos">
  173.                     <xsl:call-template name="get-number-after">
  174.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  175.                         <xsl:with-param name="position" select="$newpos"/>
  176.                         <xsl:with-param name="count" select="1"/>
  177.                     </xsl:call-template>
  178.                 </xsl:variable>
  179.                 <xsl:call-template name="svgpath2vmlpath">
  180.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  181.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $num-and-pos , ':') + $current-x  , ' ' , $current-y , ' ') "/>
  182.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  183.                     <xsl:with-param name="last-command" select="$command"/>
  184.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  + $current-x"/>
  185.                     <xsl:with-param name="current-y" select=" $current-y"/>
  186.                 </xsl:call-template>
  187.             </xsl:when>
  188.             <xsl:when test="$command = 'V' ">
  189.                 <!-- absolute vertical  lineto -->
  190.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
  191.                 <xsl:variable name="num-and-pos">
  192.                     <xsl:call-template name="get-number-after">
  193.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  194.                         <xsl:with-param name="position" select="$newpos"/>
  195.                         <xsl:with-param name="count" select="1"/>
  196.                     </xsl:call-template>
  197.                 </xsl:variable>
  198.                 <xsl:call-template name="svgpath2vmlpath">
  199.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  200.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  , ' ' ) "/>
  201.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  202.                     <xsl:with-param name="last-command" select="$command"/>
  203.                     <xsl:with-param name="current-x" select=" $current-x"/>
  204.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  205.                 </xsl:call-template>
  206.             </xsl:when>
  207.             <xsl:when test="$command = 'v' ">
  208.                 <!-- relative horizontal  lineto -->
  209.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' l ' ) "/>
  210.                 <xsl:variable name="num-and-pos">
  211.                     <xsl:call-template name="get-number-after">
  212.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  213.                         <xsl:with-param name="position" select="$newpos"/>
  214.                         <xsl:with-param name="count" select="1"/>
  215.                     </xsl:call-template>
  216.                 </xsl:variable>
  217.                 <xsl:call-template name="svgpath2vmlpath">
  218.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  219.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  + $current-y , ' ' ) "/>
  220.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  221.                     <xsl:with-param name="last-command" select="$command"/>
  222.                     <xsl:with-param name="current-x" select=" $current-x"/>
  223.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  224.                 </xsl:call-template>
  225.             </xsl:when>
  226.             <xsl:when test="$command = 'C' ">
  227.                 <!-- absolute curveto -->
  228.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/>
  229.                 <xsl:variable name="control-and-pos">
  230.                     <xsl:call-template name="get-number-after">
  231.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  232.                         <xsl:with-param name="position" select="$newpos"/>
  233.                         <xsl:with-param name="count" select="4"/>
  234.                     </xsl:call-template>
  235.                 </xsl:variable>
  236.                 <xsl:variable name="num-and-pos">
  237.                     <xsl:call-template name="get-number-after">
  238.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  239.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  240.                         <xsl:with-param name="count" select="2"/>
  241.                     </xsl:call-template>
  242.                 </xsl:variable>
  243.                 <xsl:call-template name="svgpath2vmlpath">
  244.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  245.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  246.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  247.                     <xsl:with-param name="last-command" select="$command"/>
  248.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  249.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  250.                 </xsl:call-template>
  251.             </xsl:when>
  252.             <xsl:when test="$command = 'c' ">
  253.                 <!-- relative curveto -->
  254.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/>
  255.                 <xsl:variable name="control-and-pos">
  256.                     <xsl:call-template name="get-number-after">
  257.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  258.                         <xsl:with-param name="position" select="$newpos"/>
  259.                         <xsl:with-param name="count" select="4"/>
  260.                     </xsl:call-template>
  261.                 </xsl:variable>
  262.                 <xsl:variable name="num-and-pos">
  263.                     <xsl:call-template name="get-number-after">
  264.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  265.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  266.                         <xsl:with-param name="count" select="2"/>
  267.                     </xsl:call-template>
  268.                 </xsl:variable>
  269.                 <xsl:call-template name="svgpath2vmlpath">
  270.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  271.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  272.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  273.                     <xsl:with-param name="last-command" select="$command"/>
  274.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  275.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  276.                 </xsl:call-template>
  277.             </xsl:when>
  278.             <xsl:when test="$command = 'S' ">
  279.                 <!-- absolute shorthand/smooth curveto -->
  280.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' c ' ) "/>
  281.                 <xsl:variable name="control-and-pos">
  282.                     <xsl:call-template name="get-number-after">
  283.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  284.                         <xsl:with-param name="position" select="$newpos"/>
  285.                         <xsl:with-param name="count" select="2"/>
  286.                     </xsl:call-template>
  287.                 </xsl:variable>
  288.                 <xsl:variable name="num-and-pos">
  289.                     <xsl:call-template name="get-number-after">
  290.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  291.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  292.                         <xsl:with-param name="count" select="2"/>
  293.                     </xsl:call-template>
  294.                 </xsl:variable>
  295.                 <xsl:variable name="control-1">
  296.                     <xsl:choose>
  297.                         <xsl:when test="string-length(translate($last-command, 'CcSs','')  )= 0 ">
  298.                             <xsl:variable name="previous-control-2">
  299.                                 <xsl:call-template name="get-number-before">
  300.                                     <xsl:with-param name="svg-path" select="$svg-path"/>
  301.                                     <xsl:with-param name="position" select="$position"/>
  302.                                     <xsl:with-param name="count" select="2"/>
  303.                                     <xsl:with-param name="skipcount" select="2"/>
  304.                                 </xsl:call-template>
  305.                             </xsl:variable>
  306.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  307.                         </xsl:when>
  308.                         <xsl:otherwise>
  309.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  310.                         </xsl:otherwise>
  311.                     </xsl:choose>
  312.                 </xsl:variable>
  313.                 <xsl:call-template name="svgpath2vmlpath">
  314.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  315.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  316.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  317.                     <xsl:with-param name="last-command" select="$command"/>
  318.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  319.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  320.                 </xsl:call-template>
  321.             </xsl:when>
  322.             <xsl:when test="$command = 's' ">
  323.                 <!-- absolute shorthand/smooth curveto -->
  324.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' v ' ) "/>
  325.                 <xsl:variable name="control-and-pos">
  326.                     <xsl:call-template name="get-number-after">
  327.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  328.                         <xsl:with-param name="position" select="$newpos"/>
  329.                         <xsl:with-param name="count" select="2"/>
  330.                     </xsl:call-template>
  331.                 </xsl:variable>
  332.                 <xsl:variable name="num-and-pos">
  333.                     <xsl:call-template name="get-number-after">
  334.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  335.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  336.                         <xsl:with-param name="count" select="2"/>
  337.                     </xsl:call-template>
  338.                 </xsl:variable>
  339.                 <xsl:variable name="control-1">
  340.                     <xsl:choose>
  341.                         <xsl:when test="string-length(translate($last-command, 'CcSs' , '')) = 0 ">
  342.                             <xsl:variable name="previous-control-2">
  343.                                 <xsl:call-template name="get-number-before">
  344.                                     <xsl:with-param name="svg-path" select="$svg-path"/>
  345.                                     <xsl:with-param name="position" select="$position"/>
  346.                                     <xsl:with-param name="count" select="2"/>
  347.                                     <xsl:with-param name="skipcount" select="2"/>
  348.                                 </xsl:call-template>
  349.                             </xsl:variable>
  350.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  351.                         </xsl:when>
  352.                         <xsl:otherwise>
  353.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  354.                         </xsl:otherwise>
  355.                     </xsl:choose>
  356.                 </xsl:variable>
  357.                 <xsl:call-template name="svgpath2vmlpath">
  358.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  359.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  360.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  361.                     <xsl:with-param name="last-command" select="$command"/>
  362.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  363.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  364.                 </xsl:call-template>
  365.             </xsl:when>
  366.             <xsl:when test="$command = 'Q' ">
  367.                 <!-- absolute quadratic  b├⌐zier curves  -->
  368.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' ) "/>
  369.                 <xsl:variable name="control-and-pos">
  370.                     <xsl:call-template name="get-number-after">
  371.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  372.                         <xsl:with-param name="position" select="$newpos"/>
  373.                         <xsl:with-param name="count" select="2"/>
  374.                     </xsl:call-template>
  375.                 </xsl:variable>
  376.                 <xsl:variable name="num-and-pos">
  377.                     <xsl:call-template name="get-number-after">
  378.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  379.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  380.                         <xsl:with-param name="count" select="2"/>
  381.                     </xsl:call-template>
  382.                 </xsl:variable>
  383.                 <xsl:call-template name="svgpath2vmlpath">
  384.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  385.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  386.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  387.                     <xsl:with-param name="last-command" select="$command"/>
  388.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  389.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  390.                 </xsl:call-template>
  391.             </xsl:when>
  392.             <xsl:when test="$command = 'q' ">
  393.                 <!-- relative  quadratic  b├⌐zier curves -->
  394.                 <xsl:variable name="control-and-pos">
  395.                     <xsl:call-template name="get-number-after">
  396.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  397.                         <xsl:with-param name="position" select="$newpos"/>
  398.                         <xsl:with-param name="count" select="2"/>
  399.                     </xsl:call-template>
  400.                 </xsl:variable>
  401.                 <xsl:variable name="control" select="substring-before( $control-and-pos , ':') "/>
  402.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' qb ' ,  substring-before($control,' ') + $current-x , ' '  , substring-after($control , ' ') + $current-y ) "/>
  403.                 <xsl:variable name="num-and-pos">
  404.                     <xsl:call-template name="get-number-after">
  405.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  406.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  407.                         <xsl:with-param name="count" select="2"/>
  408.                     </xsl:call-template>
  409.                 </xsl:variable>
  410.                 <xsl:variable name="number" select="substring-before($num-and-pos, ':')"/>
  411.                 <xsl:variable name="absolute-number" select="concat(substring-before($number, ' ') + $current-x  , ' ' , substring-after($number, ' ') + $current-y)"/>
  412.                 <xsl:call-template name="svgpath2vmlpath">
  413.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  414.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path   , ' ' ,  $absolute-number  , ' ') "/>
  415.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  416.                     <xsl:with-param name="last-command" select="$command"/>
  417.                     <xsl:with-param name="current-x" select=" substring-before( $absolute-number  , ' ') "/>
  418.                     <xsl:with-param name="current-y" select=" substring-after( $absolute-number   , ' ') "/>
  419.                 </xsl:call-template>
  420.             </xsl:when>
  421.             <xsl:when test="$command = 'Z' or $command = 'z' ">
  422.                 <!-- closepath -->
  423.                 <xsl:variable name="new-vml-path" select="concat($vml-path ,' x ' ) "/>
  424.                 <xsl:call-template name="svgpath2vmlpath">
  425.                     <xsl:with-param name="svg-path" select="$svg-path"/>
  426.                     <xsl:with-param name="vml-path" select=" concat($new-vml-path , ' ') "/>
  427.                     <xsl:with-param name="position" select=" $newpos  "/>
  428.                     <xsl:with-param name="last-command" select="$command"/>
  429.                     <xsl:with-param name="current-x" select=" $current-x "/>
  430.                     <xsl:with-param name="current-y" select=" $current-y"/>
  431.                 </xsl:call-template>
  432.             </xsl:when>
  433.             <xsl:otherwise>
  434.                 <xsl:value-of select="$vml-path"/>
  435.             </xsl:otherwise>
  436.         </xsl:choose>
  437.     </xsl:template>
  438.     <xsl:template name="get-number-before">
  439.         <!--  get $count number of number before current position , output format:number1 number2 ... numberN:newpostion 
  440.             skip $skipcount of numbers
  441.         -->
  442.         <xsl:param name="svg-path"/>
  443.         <xsl:param name="position" select="1"/>
  444.         <xsl:param name="count" select="1"/>
  445.         <xsl:param name="skipcount" select="0"/>
  446.         <xsl:param name="number" select="''"/>
  447.         <xsl:choose>
  448.             <xsl:when test="$count = 0">
  449.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  450.             </xsl:when>
  451.             <xsl:otherwise>
  452.                 <xsl:variable name="num-pos">
  453.                     <xsl:call-template name="get-number-position">
  454.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  455.                         <xsl:with-param name="position" select="$position"/>
  456.                         <xsl:with-param name="direction" select="-1"/>
  457.                     </xsl:call-template>
  458.                 </xsl:variable>
  459.                 <xsl:variable name="previous-num-and-pos">
  460.                     <xsl:call-template name="get-previous-number">
  461.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  462.                         <xsl:with-param name="position" select="$num-pos"/>
  463.                     </xsl:call-template>
  464.                 </xsl:variable>
  465.                 <xsl:if test="$skipcount > 0">
  466.                     <xsl:call-template name="get-number-before">
  467.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  468.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  469.                         <xsl:with-param name="count" select="$count"/>
  470.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  471.                         <xsl:with-param name="number" select="$number"/>
  472.                     </xsl:call-template>
  473.                 </xsl:if>
  474.                 <xsl:if test="$skipcount = 0">
  475.                     <xsl:variable name="new-number">
  476.                         <xsl:if test="not($count  = 1)">
  477.                             <xsl:value-of select="' '"/>
  478.                         </xsl:if>
  479.                         <xsl:value-of select=" concat( substring-before($previous-num-and-pos , ':')  , $number ) "/>
  480.                     </xsl:variable>
  481.                     <xsl:call-template name="get-number-before">
  482.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  483.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  484.                         <xsl:with-param name="count" select="$count - 1"/>
  485.                         <xsl:with-param name="skipcount" select="0"/>
  486.                         <xsl:with-param name="number" select="$new-number"/>
  487.                     </xsl:call-template>
  488.                 </xsl:if>
  489.             </xsl:otherwise>
  490.         </xsl:choose>
  491.     </xsl:template>
  492.     <xsl:template name="get-number-after">
  493.         <!--  get $count number of number after current position, output format:number1 number2 ... numberN:newpostion 
  494.             skip $skipcount of numbers
  495.         -->
  496.         <xsl:param name="svg-path"/>
  497.         <xsl:param name="position" select="1"/>
  498.         <xsl:param name="count" select="1"/>
  499.         <xsl:param name="skipcount" select="0"/>
  500.         <xsl:param name="number" select="''"/>
  501.         <xsl:choose>
  502.             <xsl:when test="$count = 0">
  503.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  504.             </xsl:when>
  505.             <xsl:otherwise>
  506.                 <xsl:variable name="num-pos">
  507.                     <xsl:call-template name="get-number-position">
  508.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  509.                         <xsl:with-param name="position" select="$position"/>
  510.                         <xsl:with-param name="direction" select="1"/>
  511.                     </xsl:call-template>
  512.                 </xsl:variable>
  513.                 <xsl:variable name="next-num-and-pos">
  514.                     <xsl:call-template name="get-next-number">
  515.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  516.                         <xsl:with-param name="position" select="$num-pos"/>
  517.                     </xsl:call-template>
  518.                 </xsl:variable>
  519.                 <xsl:if test="$skipcount > 0">
  520.                     <xsl:call-template name="get-number-after">
  521.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  522.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  523.                         <xsl:with-param name="count" select="$count"/>
  524.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  525.                         <xsl:with-param name="number" select="$number"/>
  526.                     </xsl:call-template>
  527.                 </xsl:if>
  528.                 <xsl:if test="$skipcount = 0">
  529.                     <xsl:variable name="new-number">
  530.                         <xsl:value-of select=" concat( $number , substring-before($next-num-and-pos , ':') ) "/>
  531.                         <xsl:if test="not($count  = 1)">
  532.                             <xsl:value-of select="' '"/>
  533.                         </xsl:if>
  534.                     </xsl:variable>
  535.                     <xsl:call-template name="get-number-after">
  536.                         <xsl:with-param name="svg-path" select="$svg-path"/>
  537.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  538.                         <xsl:with-param name="count" select="$count - 1"/>
  539.                         <xsl:with-param name="skipcount" select="0"/>
  540.                         <xsl:with-param name="number" select="$new-number"/>
  541.                     </xsl:call-template>
  542.                 </xsl:if>
  543.             </xsl:otherwise>
  544.         </xsl:choose>
  545.     </xsl:template>
  546.     <xsl:template name="get-number-position">
  547.         <!-- get the next number start position, direction should be 1  or -1-->
  548.         <xsl:param name="svg-path"/>
  549.         <xsl:param name="position"/>
  550.         <xsl:param name="direction" select="1"/>
  551.         <xsl:choose>
  552.             <xsl:when test="$direction  = 1 and $position > string-length($svg-path) ">0</xsl:when>
  553.             <xsl:when test="$direction  = -1 and not($position > 0)">0</xsl:when>
  554.             <xsl:otherwise>
  555.                 <xsl:variable name="curr-char">
  556.                     <xsl:if test="$direction = 1">
  557.                         <xsl:value-of select="substring($svg-path, $position , 1)"/>
  558.                     </xsl:if>
  559.                     <xsl:if test="$direction = -1">
  560.                         <xsl:value-of select="substring($svg-path, $position -1 , 1)"/>
  561.                     </xsl:if>
  562.                 </xsl:variable>
  563.                 <xsl:choose>
  564.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789' ,'')) = 0 ">
  565.                         <!-- number start-->
  566.                         <xsl:value-of select="$position"/>
  567.                     </xsl:when>
  568.                     <xsl:otherwise>
  569.                         <xsl:call-template name="get-number-position">
  570.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  571.                             <xsl:with-param name="position" select="$position + $direction"/>
  572.                             <xsl:with-param name="direction" select="$direction"/>
  573.                         </xsl:call-template>
  574.                     </xsl:otherwise>
  575.                 </xsl:choose>
  576.             </xsl:otherwise>
  577.         </xsl:choose>
  578.     </xsl:template>
  579.     <xsl:template name="get-next-number">
  580.         <!-- get the next number from current position-->
  581.         <xsl:param name="svg-path"/>
  582.         <xsl:param name="position"/>
  583.         <xsl:param name="number" select="''"/>
  584.         <xsl:choose>
  585.             <xsl:when test="$position > string-length($svg-path) ">
  586.                 <xsl:value-of select=" concat(round($number) ,  ':' , $position) "/>
  587.             </xsl:when>
  588.             <xsl:otherwise>
  589.                 <xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/>
  590.                 <xsl:choose>
  591.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  592.                         <!-- is number -->
  593.                         <xsl:call-template name="get-next-number">
  594.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  595.                             <xsl:with-param name="position" select="$position +1"/>
  596.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  597.                         </xsl:call-template>
  598.                     </xsl:when>
  599.                     <xsl:when test="string-length(translate($curr-char ,  '+-' ,'') ) = 0  and string-length($number) = 0">
  600.                         <!-- is number -->
  601.                         <xsl:call-template name="get-next-number">
  602.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  603.                             <xsl:with-param name="position" select="$position +1"/>
  604.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  605.                         </xsl:call-template>
  606.                     </xsl:when>
  607.                     <xsl:otherwise>
  608.                         <xsl:value-of select="concat( round($number) ,  ':' , $position)"/>
  609.                     </xsl:otherwise>
  610.                 </xsl:choose>
  611.             </xsl:otherwise>
  612.         </xsl:choose>
  613.     </xsl:template>
  614.     <xsl:template name="get-previous-number">
  615.         <!-- get the previous number from current position-->
  616.         <xsl:param name="svg-path"/>
  617.         <xsl:param name="position"/>
  618.         <xsl:param name="number" select="''"/>
  619.         <xsl:choose>
  620.             <xsl:when test="not($position > 0)">
  621.                 <xsl:value-of select="concat( round($number ),  ':0')"/>
  622.             </xsl:when>
  623.             <xsl:otherwise>
  624.                 <xsl:variable name="curr-char" select="substring($svg-path, $position -1 , 1)"/>
  625.                 <xsl:choose>
  626.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  627.                         <!-- is number -->
  628.                         <xsl:call-template name="get-previous-number">
  629.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  630.                             <xsl:with-param name="position" select="$position -1"/>
  631.                             <xsl:with-param name="number" select="concat($curr-char ,  $number) "/>
  632.                         </xsl:call-template>
  633.                     </xsl:when>
  634.                     <xsl:when test="string-length(translate($curr-char ,  '+-' ,'') ) = 0  and string-length($number) = 0">
  635.                         <!-- skip it -->
  636.                         <xsl:call-template name="get-previous-number">
  637.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  638.                             <xsl:with-param name="position" select="$position -1"/>
  639.                             <xsl:with-param name="number" select="$number "/>
  640.                         </xsl:call-template>
  641.                     </xsl:when>
  642.                     <xsl:when test="string-length(translate($curr-char ,  '+-' ,'') ) = 0  and string-length($number) > 0">
  643.                         <!-- finsh it with +/- -->
  644.                         <xsl:value-of select="concat( round( concat( $curr-char, $number)) ,  ':' , $position)"/>
  645.                     </xsl:when>
  646.                     <xsl:otherwise>
  647.                         <xsl:value-of select="concat( round($number) ,  ':' , $position)"/>
  648.                     </xsl:otherwise>
  649.                 </xsl:choose>
  650.             </xsl:otherwise>
  651.         </xsl:choose>
  652.     </xsl:template>
  653.     <xsl:template name="get-path-command">
  654.         <xsl:param name="svg-path"/>
  655.         <xsl:param name="position" select="1"/>
  656.         <xsl:param name="last-command"/>
  657.         <xsl:choose>
  658.             <xsl:when test="$position > string-length($svg-path) "/>
  659.             <xsl:otherwise>
  660.                 <xsl:variable name="curr-char" select="substring($svg-path, $position , 1)"/>
  661.                 <xsl:choose>
  662.                     <xsl:when test="string-length(translate($curr-char ,  'MmZzLlHhVvCcSsQqTtAa' ,'')) = 0 ">
  663.                         <!-- "MmZzLlHhVvCcSsQqTtAa" are all possiable  command chars -->
  664.                         <xsl:value-of select="concat( $curr-char , ':'  , $position +1)"/>
  665.                     </xsl:when>
  666.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789' ,'')) = 0 ">
  667.                         <!-- number start, use last command -->
  668.                         <xsl:if test="string-length($last-command) = 0">
  669.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  670.                         </xsl:if>
  671.                         <xsl:value-of select="concat( $last-command  , ':'  , $position )"/>
  672.                     </xsl:when>
  673.                     <xsl:when test="string-length(translate($curr-char ,  ', ' ,'')) = 0 ">
  674.                         <!-- space or ',' should be skip -->
  675.                         <xsl:call-template name="get-path-command">
  676.                             <xsl:with-param name="svg-path" select="$svg-path"/>
  677.                             <xsl:with-param name="position" select="$position +1"/>
  678.                             <xsl:with-param name="last-command" select="$last-command"/>
  679.                         </xsl:call-template>
  680.                     </xsl:when>
  681.                     <xsl:otherwise>
  682.                         <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
  683.                         </xsl:message>
  684.                     </xsl:otherwise>
  685.                 </xsl:choose>
  686.             </xsl:otherwise>
  687.         </xsl:choose>
  688.     </xsl:template>
  689.     <xsl:template name="svg-arc2vml-arc">
  690.         <xsl:param name="x0"/>
  691.         <xsl:param name="y0"/>
  692.         <xsl:param name="rx"/>
  693.         <xsl:param name="ry"/>
  694.         <xsl:param name="x-axis-rotation" select="0"/>
  695.         <xsl:param name="large-arc-flag" select="0"/>
  696.         <xsl:param name="sweep-flag" select="0"/>
  697.         <xsl:param name="x"/>
  698.         <xsl:param name="y"/>
  699.         <!-- Compute 1/2 distance between current and final point -->
  700.         <xsl:variable name="dx2" select="($x0 - $x) div 2"/>
  701.         <xsl:variable name="dy2" select="($y0 - $y) div 2"/>
  702.         <!--    Convert from degrees to radians -->
  703.         <xsl:variable name="rotation-radian" select="$x-axis-rotation * $pi div 180"/>
  704.         <!-- Compute (x1, y1). What are x1,y1?-->
  705.         <xsl:variable name="cos-rotation">
  706.             <xsl:call-template name="cos">
  707.                 <xsl:with-param name="x" select="$rotation-radian"/>
  708.             </xsl:call-template>
  709.         </xsl:variable>
  710.         <xsl:variable name="sin-rotation">
  711.             <xsl:call-template name="sin">
  712.                 <xsl:with-param name="x" select="$rotation-radian"/>
  713.             </xsl:call-template>
  714.         </xsl:variable>
  715.         <xsl:variable name="x1" select="$cos-rotation * $dx2 + $sin-rotation * $dy2"/>
  716.         <xsl:variable name="y1" select="-1 * $sin-rotation  * $dx2 + $cos-rotation * $dy2"/>
  717.         <!-- Make sure radii are large enough -->
  718.         <xsl:variable name="rx-abs">
  719.             <xsl:call-template name="abs">
  720.                 <xsl:with-param name="x" select="$rx"/>
  721.             </xsl:call-template>
  722.         </xsl:variable>
  723.         <xsl:variable name="ry-abs">
  724.             <xsl:call-template name="abs">
  725.                 <xsl:with-param name="x" select="$ry"/>
  726.             </xsl:call-template>
  727.         </xsl:variable>
  728.         <xsl:variable name="rx-sq" select="$rx-abs * $rx-abs"/>
  729.         <xsl:variable name="ry-sq" select="$ry-abs * $ry-abs"/>
  730.         <xsl:variable name="x1-sq" select="$x1 * $x1"/>
  731.         <xsl:variable name="y1-sq" select="$y1 * $y1"/>
  732.         <xsl:variable name="radius-check" select=" $x1-sq div $rx-sq + $y1-sq div $ry-sq "/>
  733.         <xsl:variable name="radius-check-sqrt">
  734.             <xsl:call-template name="sqrt">
  735.                 <xsl:with-param name="x" select="$radius-check"/>
  736.             </xsl:call-template>
  737.         </xsl:variable>
  738.         <xsl:variable name="new-rx">
  739.             <xsl:choose>
  740.                 <xsl:when test="$radius-check > 1">
  741.                     <xsl:value-of select="$rx-abs * $radius-check-sqrt"/>
  742.                 </xsl:when>
  743.                 <xsl:otherwise>
  744.                     <xsl:value-of select="$rx-abs"/>
  745.                 </xsl:otherwise>
  746.             </xsl:choose>
  747.         </xsl:variable>
  748.         <xsl:variable name="new-ry">
  749.             <xsl:choose>
  750.                 <xsl:when test="$radius-check > 1">
  751.                     <xsl:value-of select="$ry-abs * $radius-check-sqrt"/>
  752.                 </xsl:when>
  753.                 <xsl:otherwise>
  754.                     <xsl:value-of select="$ry-abs"/>
  755.                 </xsl:otherwise>
  756.             </xsl:choose>
  757.         </xsl:variable>
  758.         <xsl:variable name="new-ry-sq">
  759.             <xsl:choose>
  760.                 <xsl:when test="$radius-check > 1">
  761.                     <xsl:value-of select="$new-ry * $new-ry"/>
  762.                 </xsl:when>
  763.                 <xsl:otherwise>
  764.                     <xsl:value-of select="$ry-sq"/>
  765.                 </xsl:otherwise>
  766.             </xsl:choose>
  767.         </xsl:variable>
  768.         <xsl:variable name="new-rx-sq">
  769.             <xsl:choose>
  770.                 <xsl:when test="$radius-check > 1">
  771.                     <xsl:value-of select="$new-rx * $new-rx"/>
  772.                 </xsl:when>
  773.                 <xsl:otherwise>
  774.                     <xsl:value-of select="$rx-sq"/>
  775.                 </xsl:otherwise>
  776.             </xsl:choose>
  777.         </xsl:variable>
  778.         <!-- Step 2: Compute (cx1, cy1) -->
  779.         <xsl:variable name="sign">
  780.             <xsl:choose>
  781.                 <xsl:when test="$large-arc-flag = $sweep-flag">-1</xsl:when>
  782.                 <xsl:otherwise>1</xsl:otherwise>
  783.             </xsl:choose>
  784.         </xsl:variable>
  785.         <xsl:variable name="unchecked-sq" select=" (($new-rx-sq * $new-ry-sq) - ($new-rx-sq * $y1-sq) - ($new-ry-sq * $x1-sq)) div   (($new-rx-sq * $y1-sq) + ($new-ry-sq * $x1-sq)) "/>
  786.         <xsl:variable name="sq">
  787.             <xsl:choose>
  788.                 <xsl:when test=" $unchecked-sq < 0">0</xsl:when>
  789.                 <xsl:otherwise>
  790.                     <xsl:value-of select="$unchecked-sq"/>
  791.                 </xsl:otherwise>
  792.             </xsl:choose>
  793.         </xsl:variable>
  794.         <xsl:variable name="sq-sqrt">
  795.             <xsl:call-template name="sqrt">
  796.                 <xsl:with-param name="x" select="$sq"/>
  797.             </xsl:call-template>
  798.         </xsl:variable>
  799.         <xsl:variable name="coef" select="$sign * $sq-sqrt "/>
  800.         <xsl:variable name="cx1" select="$coef * $new-rx * $y1 div $new-ry"/>
  801.         <xsl:variable name="cy1" select=" -1 * $coef * $new-ry * $x1 div $new-rx"/>
  802.         <!--  Step 3: Compute (cx, cy) from (cx1, cy1) -->
  803.         <xsl:variable name="sx2" select="($x0 +$x) div 2 "/>
  804.         <xsl:variable name="sy2" select="($y0 +$y) div 2 "/>
  805.         <xsl:variable name="tmp1" select="$cos-rotation * $cx1 "/>
  806.         <xsl:variable name="tmp2" select="$cos-rotation * $cx1 "/>
  807.         <xsl:variable name="cx" select=" $sx2 + ( $cos-rotation * $cx1 - $sin-rotation * $cy1 ) "/>
  808.         <xsl:variable name="cy" select=" $sy2 + ( $sin-rotation * $cx1 + $cos-rotation * $cy1 ) "/>
  809.         <!-- Step 4: Compute angle start and angle extent -->
  810.         <xsl:variable name="ux" select="( $x1 - $cx1)  div $new-rx"/>
  811.         <xsl:variable name="uy" select="( $y1 - $cy1)  div $new-ry"/>
  812.         <xsl:variable name="vx" select="( - 1 *  $x1 - $cx1)  div $new-rx"/>
  813.         <xsl:variable name="vy" select="(- 1 *  $y1 - $cy1)  div $new-ry"/>
  814.         <xsl:variable name="n">
  815.             <xsl:call-template name="sqrt">
  816.                 <xsl:with-param name="x" select="  ($ux * $ux) + ($uy * $uy)  "/>
  817.             </xsl:call-template>
  818.         </xsl:variable>
  819.         <!--  1 * ux + 0 * uy -->
  820.         <xsl:variable name="p" select="$ux"/>
  821.         <xsl:variable name="uy-sign">
  822.             <xsl:choose>
  823.                 <xsl:when test=" $uy < 0 ">-1</xsl:when>
  824.                 <xsl:otherwise>1</xsl:otherwise>
  825.             </xsl:choose>
  826.         </xsl:variable>
  827.         <xsl:variable name="acos-pn">
  828.             <xsl:call-template name="acos">
  829.                 <xsl:with-param name="x" select="$p div $n"/>
  830.             </xsl:call-template>
  831.         </xsl:variable>
  832.         <xsl:variable name="theta" select="( $uy-sign * $acos-pn * 180 div $pi ) mod 360 "/>
  833.         <xsl:variable name="n-delta">
  834.             <xsl:call-template name="sqrt">
  835.                 <xsl:with-param name="x" select="($ux * $ux + $uy * $uy) * ($vx * $vx + $vy * $vy)"/>
  836.             </xsl:call-template>
  837.         </xsl:variable>
  838.         <xsl:variable name="p-delta" select="$ux * $vx + $uy * $vy"/>
  839.         <xsl:variable name="vy-sign">
  840.             <xsl:choose>
  841.                 <xsl:when test="($ux * $vy - $uy * $vx)   < 0 ">-1</xsl:when>
  842.                 <xsl:otherwise>1</xsl:otherwise>
  843.             </xsl:choose>
  844.         </xsl:variable>
  845.         <xsl:variable name="acos-pn-delta">
  846.             <xsl:call-template name="acos">
  847.                 <xsl:with-param name="x" select="$p-delta div $n-delta"/>
  848.             </xsl:call-template>
  849.         </xsl:variable>
  850.         <xsl:variable name="unchecked-delta" select="$vy-sign * $acos-pn-delta * 180 div $pi "/>
  851.         <xsl:variable name="delta">
  852.             <xsl:choose>
  853.                 <xsl:when test=" $sweep-flag = 0 and $unchecked-delta > 0 ">
  854.                     <xsl:value-of select=" ($unchecked-delta - 360) mod 360 "/>
  855.                 </xsl:when>
  856.                 <xsl:when test=" $sweep-flag = 1 and $unchecked-delta < 0 ">
  857.                     <xsl:value-of select=" ($unchecked-delta + 360) mod 360 "/>
  858.                 </xsl:when>
  859.                 <xsl:otherwise>
  860.                     <xsl:value-of select=" $unchecked-delta  mod 360 "/>
  861.                 </xsl:otherwise>
  862.             </xsl:choose>
  863.         </xsl:variable>
  864.         <xsl:value-of select="concat ($cx,  ' ' , $cy, ' ' ,  $rx, ' ' ,  $ry, ' ' ,  $theta, ' ' , $delta,  ' ' , $x-axis-rotation) "/>
  865.     </xsl:template>
  866. </xsl:stylesheet>
  867.